<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>OCILIB (C and C++ Driver for Oracle): Aborting long operations</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">OCILIB (C and C++ Driver for Oracle)
   &#160;<span id="projectnumber">4.2.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>About</span></a></li>
      <li><a href="modules.html"><span>Documentation</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group___ocilib_c_api_abort.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Aborting long operations<div class="ingroups"><a class="el" href="group___ocilib_c_api.html">C API</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>The Oracle OCI provides the ability to establish a server connection in :</p>
<ul>
<li>blocking mode: each call to an OCI function returns control to the application when the call completes</li>
<li>non-blocking mode (based on polling paradigm) : the application have to call each function until its has completed its job</li>
</ul>
<p>OCILIB implements OCI in blocking mode. The application has to wait for OCI calls to complete to continue.</p>
<p>Some operations can be long to be processed by the server.</p>
<p>In order to cancel the current pending call, OCILIB provides <a class="el" href="group___ocilib_c_api_abort.html#gaf34a39ddfb3b6677eab1add1a4052e4d" title="Perform an immediate abort of any currently Oracle OCI call. ">OCI_Break()</a> that cancel the last internal OCI Call and then raise an OCI abortion error code.</p>
<dl class="section note"><dt>Note</dt><dd>Any call to <a class="el" href="group___ocilib_c_api_abort.html#gaf34a39ddfb3b6677eab1add1a4052e4d" title="Perform an immediate abort of any currently Oracle OCI call. ">OCI_Break()</a> has to be done from a separate thread because the thread that has executed a long OCI call is waiting for its OCI call to complete.</dd></dl>
<dl class="section user"><dt>Example</dt><dd><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;windows.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;process.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;ocilib.h&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="comment">/* Example on Microsoft platform */</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">static</span> HANDLE evt;</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> long_oracle_call(<span class="keywordtype">void</span> *data)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="group___ocilib_c_api_datatypes.html#ga4b016f1bd7de508b1a919e34b12aa83d">OCI_Statement</a> *st  = <a class="code" href="group___ocilib_c_api_statements.html#ga335822f983af0fb5c529431f06a9a17b">OCI_StatementCreate</a>((<a class="code" href="group___ocilib_c_api_datatypes.html#ga2135d3b5341ebbaae1f54d62873ecf77">OCI_Connection</a> *) data); </div>
<div class="line">    <a class="code" href="group___ocilib_c_api_datatypes.html#gae0c7aa9c507975d21ca6c261081ba753">OCI_Resultset</a> *rs;</div>
<div class="line"></div>
<div class="line">    <span class="comment">/* execute a query that takes a long time to process */</span></div>
<div class="line"></div>
<div class="line">    <a class="code" href="group___ocilib_c_api_statements.html#ga8b2b66994f847d9f0b6b0efe4a13ccf3">OCI_ExecuteStmt</a>(st, <span class="stringliteral">&quot;select code, content from huge_table&quot;</span>);</div>
<div class="line"></div>
<div class="line">    rs = <a class="code" href="group___ocilib_c_api_fetching.html#gaf2a9e28b66a9538ba0ffb62bffb87c16">OCI_GetResultset</a>(st);</div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">while</span> (<a class="code" href="group___ocilib_c_api_fetching.html#ga36ac26dcea78f6074421781e401f97ba">OCI_FetchNext</a>(rs))</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;%i - %s&quot;</span>, <a class="code" href="group___ocilib_c_api_fetching.html#gaa8d80dc30b2012eaddd13efa9dfb711d">OCI_GetInt</a>(rs, 1), <a class="code" href="group___ocilib_c_api_fetching.html#ga2a3252984f674fab5358c94d58c689b2">OCI_GetString</a>(rs, 2));</div>
<div class="line">    }</div>
<div class="line"></div>
<div class="line">    SetEvent(evt);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">   <a class="code" href="group___ocilib_c_api_datatypes.html#ga2135d3b5341ebbaae1f54d62873ecf77">OCI_Connection</a> *cn;</div>
<div class="line"></div>
<div class="line">   <span class="keywordflow">if</span> (!<a class="code" href="group___ocilib_c_api_initialization.html#ga01464863ddd68393106b63fb8cc1ead1">OCI_Initialize</a>(NULL, NULL, OCI_ENV_DEFAULT))</div>
<div class="line">        <span class="keywordflow">return</span> EXIT_FAILURE;</div>
<div class="line"></div>
<div class="line">    cn = <a class="code" href="group___ocilib_c_api_connections.html#ga5cd867ad94bdc4a3bbfdef24452262e0">OCI_ConnectionCreate</a>(<span class="stringliteral">&quot;db&quot;</span>, <span class="stringliteral">&quot;usr&quot;</span>, <span class="stringliteral">&quot;pwd&quot;</span>, OCI_SESSION_DEFAULT);</div>
<div class="line">    evt = CreateEvent(0, TRUE, FALSE, 0);</div>
<div class="line"></div>
<div class="line">    _beginthread(long_oracle_call, 0, cn);</div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">if</span> (WaitForSingleObject(evt, 10000) != WAIT_OBJECT_0)</div>
<div class="line">    {</div>
<div class="line">        <a class="code" href="group___ocilib_c_api_abort.html#gaf34a39ddfb3b6677eab1add1a4052e4d">OCI_Break</a>(cn);</div>
<div class="line">        Sleep(2000);</div>
<div class="line">    }</div>
<div class="line"></div>
<div class="line">    <a class="code" href="group___ocilib_c_api_initialization.html#ga639706aa8e9689c7ebffc018fac6d3ae">OCI_Cleanup</a>();</div>
<div class="line"></div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span> EXIT_SUCCESS;</div>
<div class="line">}</div>
</div><!-- fragment --> </dd></dl>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaf34a39ddfb3b6677eab1add1a4052e4d"><td class="memItemLeft" align="right" valign="top">OCI_EXPORT boolean OCI_API&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___ocilib_c_api_abort.html#gaf34a39ddfb3b6677eab1add1a4052e4d">OCI_Break</a> (<a class="el" href="group___ocilib_c_api_datatypes.html#ga2135d3b5341ebbaae1f54d62873ecf77">OCI_Connection</a> *con)</td></tr>
<tr class="memdesc:gaf34a39ddfb3b6677eab1add1a4052e4d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform an immediate abort of any currently Oracle OCI call.  <a href="#gaf34a39ddfb3b6677eab1add1a4052e4d">More...</a><br /></td></tr>
<tr class="separator:gaf34a39ddfb3b6677eab1add1a4052e4d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gaf34a39ddfb3b6677eab1add1a4052e4d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">OCI_EXPORT boolean OCI_API OCI_Break </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group___ocilib_c_api_datatypes.html#ga2135d3b5341ebbaae1f54d62873ecf77">OCI_Connection</a> *&#160;</td>
          <td class="paramname"><em>con</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;ocilib.h&gt;</code></p>

<p>Perform an immediate abort of any currently Oracle OCI call. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">con</td><td>- connection handle</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The current call will abort and generate an error</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Returns FALSE if connection handle is NULL otherwise TRUE </dd></dl>

<p>Referenced by <a class="el" href="classocilib_1_1_connection.html#a234a2ef41d73c687a010c55d5ade874e">ocilib::Connection::Break()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Mar 21 2016 22:26:37 for OCILIB (C and C++ Driver for Oracle) by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
  </ul>
</div>
</body>
</html>
